<%--
  Created by IntelliJ IDEA.
  User: hjb
  Time: 下午 11:17
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>cart</title>
    <%@include file="/pages/common/head.jsp"%>
    <link type="text/css" rel="stylesheet" href="static/css/style.css" >
</head>
<body>
<div id="main">

    <table>
        <tr>
            <td>名称</td>
            <td>代号</td>
            <td>定金</td>
            <td>全额</td>
            <td>操作</td>
        </tr>
        <c:if test="${empty sessionScope.cart.items}">
            <%--如果购物车空的情况--%>
            <tr>
                <td colspan="5"><a href="index.jsp">你还没有加入任何旅行团，是外面的风景魅力不足了吗</a> </td>
            </tr>
        </c:if>
        <c:if test="${not empty sessionScope.cart.items}">
            <%--如果购物车非空的情况--%>
            <c:forEach items="${sessionScope.cart.items}" var="entry">
                <tr>
                    <td>${entry.value.name}</td>
                    <td>${entry.value.code}</td>
                    <td>${entry.value.deposit}</td>
                    <td>${entry.value.basicPrice}</td>
                    <td><a class="deleteItem" href="cartServlet?action=deleteItem&id=${entry.value.id}">退出</a></td>
                </tr>
            </c:forEach>
        </c:if>
    </table>
    <%--如果购物车非空才输出页面的内容--%>
    <c:if test="${not empty sessionScope.cart.items}">
        <div class="cart_info">
            <span class="cart_span">你已加入<span class="b_count">${sessionScope.cart.totalCount}</span>个旅行团</span>
            <span class="cart_span">需支付定金<span class="b_price">${sessionScope.cart.totalDeposit}</span>元</span>
            <span class="cart_span">需支付全额<span class="b_price">${sessionScope.cart.totalBasicPrice}</span>元</span>
            <span class="cart_span"><a id="clearCart" href="cartServlet?action=clear">一键退出</a></span>
            <span class="cart_span"><a href="orderServlet?action=createOrder&payType=deposit">支付定金</a></span>
            <span class="cart_span"><a href="orderServlet?action=createOrder&payType=basicPrice">支付全额</a></span>
        </div>
    </c:if>
    <script type="text/javascript">
        $(function () {
            // 给 【删除】绑定单击事件
            $("a.deleteItem").click(function () {
                return confirm("你确定要推出【" + $(this).parent().parent().find("td:first").text() +"】吗?")
            });
            // 给清空购物车绑定单击事件
            $("#clearCart").click(function () {
                return confirm("你确定要退出所有旅行团吗?");
            })

        });
    </script>
</div>
</body>
</html>
